<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>GESTIONE ACCOUNT</title>
<script type="text/javascript" src="../../js/immagini.js"></script>
<link href="../../layout.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="js/immagini.js"></script>
</head>
<%@page import="utility.connections"%>
<%! String user,type,matr,cogn,pwd,nome,cognome,email,matricola,tipologia; %>
<%  
		
			if (session.getAttribute("user")==null)
			response.sendRedirect("loginerr.jsp");
			
			else
			{
	
			user = session.getAttribute("user").toString().toLowerCase();
			type = session.getAttribute("type").toString();
			matr = session.getAttribute("matricola").toString();
			nome = session.getAttribute("nome").toString();
			cogn = session.getAttribute("cognome").toString();
			}
%>
		
<body>
<table width="700" height="422" border="0" align="center">
  <tr>
    <td align="center" valign="middle"></td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="100%" border="0">
      <tr>
        <td width="100%" align="center"><div align="left">
          <p class="style3">
<%
	try {
		Statement st = connections.getStatement();
		
		String qry = "select a.matricola as matricola, a.username as username, a.password as password," 
		           + "a.email as email, a.tipologia as tipologia,"
		           + "p.nome as nome, p.cognome as cognome "
				   + "from account a, personale p where a.username = '" + user
				   + "' and a.matricola=p.matricola";
		ResultSet rs = st.executeQuery(qry);
		if (rs.next())
		{
			user=rs.getString("username");
			pwd=rs.getString("password");
			nome=rs.getString("nome");
			cognome=rs.getString("cognome");
			matricola=rs.getString("matricola");
			email=rs.getString("email");
			switch(rs.getInt("tipologia"))
					{
				case 1: tipologia = "Amministratore";break;
				case 2: tipologia = "Addetto Amministrativo";break;
				case 3: tipologia = "Dipendente";break;
					}
		}
		else
		{
			session=request.getSession(true);
			session.invalidate();
			
			response.sendRedirect("loginerr.jsp");
		}
		
		rs.close();
		
	} catch (SQLException e) {
		e.printStackTrace();
	}	
%>
		</p>
        </div></td>
        </tr>
      <tr>
        <td class="style2"><p align="center"><strong>Dati dell'utente  </strong></p>
          <hr></td>
        </tr>
      <tr>
        <td class="style2"><div align="center">
          <table width="100%" border="0">
            <tr>
              <td width="27%"><div align="right">user:</div></td>
              <td width="32%"><input type="text" name="txtuser" size="60" value="<%=user%>" readonly="readonly"></input></td>
              </tr>
            <tr>
              <td><div align="right">password:</div></td>
              <td><input type="text" name="txtuser" size="60" value="<%=pwd%>" readonly="readonly"></input></td>
              </tr>
            <tr>
              <td><div align="right">tipologia:</div></td>
              <td><input type="text" name="txtuser" size="60" value="<%=tipologia%>" readonly="readonly"></input></td>
              </tr>
            <tr>
              <td><div align="right">email:</div></td>
              <td><input type="text" name="txtuser" size="60" value="<%=email%>" readonly="readonly"></input></td>
              </tr>
            <tr>
              <td><div align="right">matricola:</div></td>
              <td><input type="text" name="txtuser" size="60" value="<%=matricola%>" readonly="readonly"></input></td>
              </tr>
            <tr>
              <td colspan="2">
                <div align="center">
                  <form name="frmPwd" action="modifica_password.jsp" method="post">
                    <img name="btnPwd" src="../../images/Crystal/pen/png/48.png" width="48" height="48" 
					     onClick="frmPwd.submit();" alt="MODIFICA PASSWORD" 
						 onMouseOver="loadImg(btnPwd,'../../images/Crystal/pensils/png/48.png');"
						 onMouseOut="loadImg(btnPwd,'../../images/Crystal/pen/png/48.png');">
                    <img name="btnOut" src="../../images/Crystal/usergreen/png/48.png" width="48" height="48" 
					     onClick="frmOut.submit();" alt="MODIFICA PASSWORD" 
						 onMouseOver="loadImg(btnOut,'../../images/Crystal/smiley/png/48.png');"
						 onMouseOut="loadImg(btnOut,'../../images/Crystal/usergreen/png/48.png');">
                    <img name="btnOut" src="../../images/Crystal/cut/png/48.png" width="48" height="48" 
					     onClick="frmOut.submit();" alt="MODIFICA PASSWORD" 
						 onMouseOver="loadImg(btnOut,'../../images/Crystal/smiley/png/48.png');"
						 onMouseOut="loadImg(btnOut,'../../images/Crystal/usergreen/png/48.png');">
                    <img name="btnOut" src="../../images/Crystal/left/png/48.png" width="48" height="48" 
					     onClick="frmOut.submit();" alt="MODIFICA PASSWORD" 
						 onMouseOver="loadImg(btnOut,'../../images/Crystal/smiley/png/48.png');"
						 onMouseOut="loadImg(btnOut,'../../images/Crystal/usergreen/png/48.png');">
                  </form>
                </div></td>
              </tr>
          </table>
          </div></td>
        </tr>
    </table>
      <hr></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#000099"><div align="right" class="style4">ACCOUNT DIPENDENTE </div></td>
  </tr>
</table>
</body>
</html>
